package com.example.thread.d1线程常用的api;

public class MyThread2 {
    public static void main(String[] args) throws InterruptedException {
        MyThreadTest2 m1 = new MyThreadTest2();
        m1.start();
        // join方法，作用，让当前调用这个方法的线程先执行完
        m1.join();

        MyThreadTest2 m2 = new MyThreadTest2();
        m2.start();
        // join方法，作用，让当前调用这个方法的线程先执行完
        m2.join();

        for (int i = 0; i < 5; i++) {
            System.out.println("主线程"+i);
        }
    }
}
class MyThreadTest2 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+"子线程"+i);
        }
    }
}
